<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>阳光成单系统</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="./css/x-admin.css" media="all">
</head>
<body>
	<div class="x-nav">
		<span class="layui-breadcrumb"> <a><cite>首页</cite></a> <a><cite>会员管理</cite></a>
			<a><cite>权限规则</cite></a>
		</span> <a class="layui-btn layui-btn-small"
			style="line-height: 1.6em; margin-top: 3px; float: right"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="layui-icon" style="line-height: 30px">ဂ</i></a>
	</div>
	<div class="x-body">
		<form class="layui-form x-center" onsubmit="return false"
			id="form_chanPingiangqing" style="width: 100%">
			<div class="layui-form-pane" style="margin-top: 15px;">
				<div class="layui-form-item">
					<div class="layui-input-inline">
						<select name="fenleiId" id="select_chanPinFenLei">
							<option value="">请选择分类</option>
						</select>
					</div>
					<div class="layui-input-inline">
						<input type="text" name="chanPinName" placeholder="请输入你想要的商品名称"
							autocomplete="off" class="layui-input">
					</div>
					

					<div class="layui-input-inline">
						<input type="text" name="qiShiJiaGe" placeholder="请输入您预期的最低价格"
							autocomplete="off" class="layui-input">
					</div>
					<div class="layui-input-inline">
						<input type="text" name="jieShuJiaGe" placeholder="请输入您预期的最高价格"
							autocomplete="off" class="layui-input">
					</div>
					<div class="layui-input-inline">
						<input type="text" name="chanPinPaiZi" placeholder="请输入你想要购买商品的品牌"
						style="width: 200px"	autocomplete="off" class="layui-input">
					</div>
					<div class="layui-input-inline">
						
						<select name="shiFouGuoqi">
							<option value="">是否过期</option>
							<option value="是">是</option>
							<option value="否">否</option>
						</select>
					
					</div>
					<div class="layui-input-inline">
						
							<select name="shiFouXianLiang">
							<option value="">是否限量</option>
							<option value="是">是</option>
							<option value="否">否</option>
						</select>
					</div>
					<div class="layui-input-inline">
						<input type="text" name="baoZhiQi" placeholder="保质期(年)"
							autocomplete="off" class="layui-input">
					</div>
					
					<div class="layui-input-inline">
						<input type="text" name="kouWei" placeholder="请输入您的口味"
							autocomplete="off" class="layui-input">
					</div>
					
					<div class="layui-input-inline" style="width: 80px">
						<button class="layui-btn" onclick="getChanPingXiangQingWhereByPage()" lay-filter="*">
							<i class="layui-icon">&#xe608;</i>搜索
						</button>
					</div>
					<div class="layui-input-inline" style="width: 80px">
						<button class="layui-btn" onclick="member_add('添加产品详情','chanPingXiangQingTianJia.html','700','500')">
							<i class="layui-icon">&#xe608;</i>添加
						</button>
					</div>
				</div>
			</div>
		</form>
		<xblock>
		<button class="layui-btn layui-btn-danger" onclick="delAll()">
			<i class="layui-icon">&#xe640;</i>批量删除
		</button>
		<span class="x-right" style="line-height: 40px">共有数据：88 条</span></xblock>
		<table class="layui-table">
			<thead>
				<tr>
					<th><input type="checkbox" name="" value=""></th>
					<th>编号</th>
					<th>名称</th>
					<th>地址</th>
					<th>售价</th>
					<th>市场价</th>
					<th>品牌</th>
					<th>是否过期</th>
					<th>是否限量</th>
					<th>保质期</th>
					<th>加工坊</th>
					<th>口味</th>
					<th>生产商</th>
					<th>重量</th>
					<th>图片</th>
					<th>所属分类</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody id="tbody_chanPingXiangQing">

			</tbody>
		</table>

		<div id="page"></div>
	</div>
	<script src="./lib/layui/layui.js" charset="utf-8"></script>
	<script src="./js/x-layui.js" charset="utf-8"></script>
	<script>
	var  laypag=null;
	
            layui.use(['element','laypage','layer','form'], function(){
                $ = layui.jquery;//jquery
              	form=layui.form;
              layer = layui.layer;//弹出层
              laypage = layui.laypage;
             $(function(){
            	 selChanPingXiangQingByPage();
            	 selChanPingFenLei();
             })

              
            })

              //以上模块根据需要引入

            //批量删除提交
             function delAll () {
                layer.confirm('确认要删除吗？',function(index){
                    //捉到所有被选中的，发异步进行删除
                    layer.msg('删除成功', {icon: 1});
                });
             }
            //多条件查询条数
            function selChanPingXiangQingByPage(){
            	//根据产品id查询长度
            	$.post("../adminchanpingxiangqing?reqName=selChanPingXiangQingId",{},function(res){
            		laypage.render({
            		    elem: 'page', //注意，这里的 test1 是 ID，不用加 # 号
            		    count: res, //数据总数，从服务端得到
            			limit :5,
            			jump: function(obj, first){
            			    selAllChanPingXiangQing(obj.curr,obj.limit)
            			  }  
            	  });
            	},"json")
            	  
            }
            
            //查询所有条数
            function getChanPingXiangQingWhereByPage(){
            	//查询产品详情的长度
            	$.post("../adminchanpingxiangqing?reqName=getChanPingXiangQingWhereByPage",$("#form_chanPingiangqing").serialize(),function(res){
            		 console.log(res);
            		laypage.render({
            		    elem: 'page', //注意，这里的 test1 是 ID，不用加 # 号
            		    count: res, //数据总数，从服务端得到
            			limit :5,
            			jump: function(obj, first){
            			    selAllChanPingXiangQing(obj.curr,obj.limit)
            			  }  
            	  });
            	},"json")
            	  
            }

            //-编辑
            function chanPingXiangQing_edit (title,url,id,w,h) {
            	sessionStorage.setItem("cpxqid",id);
                x_admin_show(title,url,w,h); 
            }
            
            /*删除*/
            function del_chanPingXiangQing(obj,id){
                layer.confirm('确认要删除吗？',function(index){
                    //发异步删除数据
                    $.post("../adminchanpingxiangqing?reqName=delChanPinXiangQingId",{
                    	chanPingId:id
                    },function(res){
                    	
                    	if(res.success){
                    		layer.msg(res.message,{icon:1,time:2000});
                    		  $(obj).parents("tr").remove();
                    		  getChanPingXiangQingWhereByPage();
                    	}else{
                    		layer.msg(res.message,{icon:2,time:2000});
                    	}
                    },"json")
                  
                    
                });
            }
            
            //查询所有数据
            function selAllChanPingXiangQing(page,size){
            	$("#tbody_chanPingXiangQing").html("");
            	$.post("../adminchanpingxiangqing?reqName=getChanPingXiangQingWhere",
            	$("#form_chanPingiangqing").serialize()+"&page="+page+"&size="+size
            	,function(res){
            		for(var i=0;i<res.length;i++){
            			$("#tbody_chanPingXiangQing").append(`
            					 <tr>
                                <td>
                                    <input type="checkbox" value="1" name="">
                                </td>
                                <td>
                                    ${res[i].chanPingId}
                                </td>
                                    <td>
                                    ${res[i].chanPinName}
                                </td>
                                    <td>
                                    ${res[i].chanPinDiZhi}
                                </td>
                                    <td>
                                    ${res[i].chanPinShouJia}
                                </td>
                                    <td>
                                    ${res[i].chanPinShiChangJia}
                                </td>
                                    <td>
                                    ${res[i].chanPinPaiZi}
                                </td>
                                    <td>
                                    ${res[i].shiFouGuoqi}
                                </td>
                                    <td>
                                    ${res[i].shiFouXianLiang}
                                </td>
                                    <td>
                                    ${res[i].baoZhiQi}
                                </td>
                                    <td>
                                    ${res[i].jiaGongFang}
                                </td>
                                    <td>
                                    ${res[i].kouWei}
                                </td>
                                    <td>
                                    ${res[i].shenChangShang}
                                </td>
                                <td>
                                ${res[i].zhongLiang}
                                </td>
                                <td>
                                <img src="../${res[i].imgs}"/>
                                
                                </td>
                                <td>
                                ${res[i].leiMing}
                                </td>
                                <td class="td-manage">
                                    <a title="编辑" href="javascript:;" onclick="chanPingXiangQing_edit('编辑','chanPingXiangQing_edit.html', ${res[i].chanPingId},'','510')"
                                    class="ml-5" style="text-decoration:none">
                                        <i class="layui-icon">&#xe642;</i>
                                    </a>
                                    <a title="删除" href="javascript:;" onclick="del_chanPingXiangQing(this, ${res[i].chanPingId})" 
                                    style="text-decoration:none">
                                        <i class="layui-icon">&#xe640;</i>
                                    </a>
                                </td>
                            </tr>		
            					
            					
            					
            			`);
            		}
            		
            		
            	},"json")
            }
            
            
            function selChanPingFenLei(){
            	$.post("../adminchanpinfenlei?reqName=selChanPinFenLei",{
            	},function(res){
	            		for(var i=0;i<res.length;i++){
	            			$("#select_chanPinFenLei").append("<option value='"+res[i].chanPinId+"'>"+res[i].leiMing+"</option>");
	            			form.render("select");
	            			
	            		}
	            	},"json");
            }
            
            function member_add(title,url,w,h){
                x_admin_show(title,url,w,h);
            }
            </script>

</body>
</html>